package java_learn.java_jinjie.Stream流;

import java.util.stream.Stream;

/**
 * Stream流中的常用方法_concat:用于把流组合到一起
 * 如果有两个流，希望合并成为一个流，那么可以使用Stream接口的静态方法concat
 * static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b)
 *
 * @Author: 李浩然
 * @Date: 2021/5/20 6:17 下午
 */
public class Demo02Concat {
    public static void main(String[] args) {
        //创建一个Stream流
        Stream<String> stream1 = Stream.of("张三丰", "张翠山", "赵敏", "周芷若", "张无忌");
        //获取一个Stream流
        String[] arr = {"美羊羊", "喜洋洋", "懒洋洋", "灰太狼", "红太狼"};
        Stream<String> stream2 = Stream.of(arr);
        Stream<String> stream = Stream.concat(stream1, stream2);
        stream.forEach(s -> System.out.println(s));
    }
}
